﻿<%@ Page Culture="auto" UICulture="auto" Title="Using templates" Language="C#" MasterPageFile="~/Site.Master"
    AutoEventWireup="true" CodeBehind="Templates.aspx.cs" Inherits="BM.Tools.WebControls.MForm.Example.Display.Templates" %>

<%@ Register Assembly="BM.Tools.WebControls.MForm" Namespace="BM.Tools.WebControls.MForm.Controls"
    TagPrefix="mf" %>
<%@ Register Assembly="BM.Tools.WebControls.MForm" Namespace="BM.Tools.WebControls.MForm.Controls.Additions"
    TagPrefix="mfadd" %>
<%@ Register Assembly="BM.Tools.WebControls.MForm" Namespace="BM.Tools.WebControls.MForm.Controls.Modifiers"
    TagPrefix="mfmod" %>
<%@ Register TagPrefix="mftitle" Namespace="BM.Tools.WebControls.MForm.Controls.Titles"
    Assembly="BM.Tools.WebControls.MForm" %>
<%@ Register TagPrefix="contents" TagName="ArtGallery" Src="~/Display/UserControls/ArtGalleryContent.ascx" %>
<%@ Register TagPrefix="contents" TagName="Museum" Src="~/Display/UserControls/MuseumContent.ascx" %>
<%@ Register TagPrefix="contents" TagName="Cinema" Src="~/Display/UserControls/CinemaContent.ascx" %>
<%@ Register TagPrefix="contents" TagName="Pub" Src="~/Display/UserControls/PubContent.ascx" %>
<%@ Register TagPrefix="contents" TagName="Restaurant" Src="~/Display/UserControls/RestaurantContent.ascx" %>
<asp:Content runat="server" ContentPlaceHolderID="Demonstration">
    <p>
        Click the City activities title to see what items can be added.
    </p>
    <p>
        Each of the city activities is specified as a user control.
    </p>
    <p>
        The same example will be used multiple times opn the next pages to show using different
        displays.
    </p>
    <mf:RootValidator runat="server" ControlToValidate="Root1" />
    <mf:Root ID="Root1" runat="server">
        <UriMappings>
            <mf:UriMapping Prefix="xs" Namespace="http://www.w3.org/2001/XMLSchema"></mf:UriMapping>
            <mf:UriMapping Prefix="" Namespace=""></mf:UriMapping>
        </UriMappings>
        <Contents>
            <mf:Branch Name="CityActivities" runat="server">
                <Contents>
                    <mf:Branch Name="ArtGallery" runat="server" MaxOccurs="100" MinOccurs="0">
                        <Contents>
                            <contents:ArtGallery runat="server" />
                        </Contents>
                    </mf:Branch>
                    <mf:Branch Name="Museum" runat="server" MaxOccurs="100" MinOccurs="0">
                        <Contents>
                            <contents:Museum runat="server" />
                        </Contents>
                    </mf:Branch>
                    <mf:Branch Name="Cinema" runat="server" MaxOccurs="100" MinOccurs="0">
                        <Contents>
                            <contents:Cinema runat="server" />
                        </Contents>
                    </mf:Branch>
                    <mf:Branch Name="Pub" runat="server" MaxOccurs="100" MinOccurs="0">
                        <Contents>
                            <contents:Pub runat="server" />
                        </Contents>
                    </mf:Branch>
                    <mf:Branch Name="Restaurant" runat="server" MaxOccurs="100" MinOccurs="0">
                        <Contents>
                            <contents:Restaurant runat="server" />
                        </Contents>
                    </mf:Branch>
                </Contents>
            </mf:Branch>
        </Contents>
    </mf:Root>
</asp:Content>
<asp:Content ID="Content1" ContentPlaceHolderID="Description" runat="server">
    <p>
        As previously mentioned, each OffspringsOwner (the Root control, the Choice control
        and the Branch control) contains a <code>Contents</code> property, which is used
        to specify this control's children.
    </p>
    <p>
        Because these children may be rendered more than once (that depends on the <code>Min</code>/<code>MaxOccurs</code>
        properties and the input xml), the inside of <code>Contents</code> is a template,
        that is be instantiated on instance control creation.
    </p>
    <p>
        In order to make code maintenance easier, these templates may be chunked and their
        common parts may be extracted. This needs some copy-paste manual work.
    </p>
    <p>
        Let's consider the following example: the form collects data about possible city
        activities. All of the activities share some data (the address, the opening hours,
        etc.) but on the other hand all of them have some custom fields.
    </p>
    <div class="Remark">
        <p>
            The schema for this example is in <code>~/Schemas/Display.xsd</code> file.</p>
    </div>
    <p>
        For the purpose of this example, the user controls for each of the activities have
        been extracted. When you look into the activities (they are in <code>~/Display/UserControls</code>
        folder), you will see that the common part of all the activities has been extracted
        into a separate user control. Now if you want to change the common part of all the
        activities, you have to do it only in one place.
    </p>
</asp:Content>
